/**
 * websocket 数据发送到客户端
 * 数据来源是主机ros
 */
package websocket

import (
	"encoding/json"
	"iron_man_comm/src/common/log"
)

type RosMessage struct {
	Cmd  string      `json:"cmd"`
	Data interface{} `json:"data"`
}

/**
 * @brief:  发送数据
 * @author: haitao.lin
 */
func (s *IotServer) sendTopicData(cmd string, data interface{}) {
	msg := RosMessage{
		Cmd:  cmd,
		Data: data,
	}
	bytes, err := json.Marshal(msg)
	if err != nil {
		log.Error("send topic data fail, data: %v, json marshal fail, err: %s", data, err.Error())
		return
	}
	s.writeWSData(bytes)
}

type DownViewSignalData struct {
	LeftFront  bool `json:"leftFront"`  //左前
	RightFront bool `json:"rightFront"` //右前
	LeftAfter  bool `json:"leftAfter"`  //左后
	RightAfter bool `json:"rightAfter"` //右后
}

type DownViewCodeData struct {
	LeftFront  uint16 `json:"leftFront"`  //左前
	RightFront uint16 `json:"rightFront"` //右前
	LeftAfter  uint16 `json:"leftAfter"`  //左后
	RightAfter uint16 `json:"rightAfter"` //右后
}

type BumpSignalData struct {
	Left  bool `json:"left"`
	Right bool `json:"right"`
}

type DropSignalData struct {
	Left  bool `json:"left"`
	Right bool `json:"right"`
}

type InstallSignal struct {
	DustBox  bool `json:"dustBox"`
	WaterBox bool `json:"waterBox"`
	LeftMop  bool `json:"leftMop"`
	RightMop bool `json:"rightMop"`
}

type ReachSignal struct {
	RollBrushUp  bool `json:"rollBrushUp"`
	EdgeBrushOut bool `json:"edgeBrushOut"`
	EdgeBrushIn  bool `json:"edgeBrushIn"`
	MopOut       bool `json:"mopOut"`
	MopIn        bool `json:"mopIn"`
	LeftMopUp    bool `json:"leftMopUp"`
	RightMopUp   bool `json:"rightMopUp"`
}

type FloorMaterial struct {
	Type uint8 `json:"type"`
}
type CarpetType struct {
	Type uint8 `json:"type"`
}
